{% extends "djangobmf/module_base.html" %}

{% load djangobmf_forms %}
{% load i18n %}

{% block base_buttons %}
<div class="btn-toolbar pull-left" role="toolbar">
{% if files %} 
  <div class="btn-group">
    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> <span class="caret"></span> {% trans "Files" %} {{ files.count }}</button>
    <ul class="dropdown-menu" role="menu">
      {% for file in files %}
      <li><a href="{{ file.bmffile_download }}">{{ file }}<br /><small>{{ file.size|filesizeformat }}</small></a></li>
      {% endfor %}
    </ul>
  </div>
{% endif %}
</div>
<div class="btn-toolbar pull-right" role="toolbar">
    {% if bmfmodule.can_clone %}
    <div class="btn-group">
        <a class="btn btn-bmfclone" href="{% get_bmf_url object "clone" %}">
            <span class="glyphicon glyphicon-duplicate"></span>
        </a>
    </div>
    {% endif %}

    {% if bmfmodule.report_views %}
        {% if bmfmodule.report_views|length > 1 %}
        <div class="btn-group">
            <button type="button" class="btn btn-bmfreport dropdown-toggle" data-toggle="dropdown">
                <span class="glyphicon glyphicon-print"></span> {% trans "Report" %}
                <span class="caret"></span>
            </button>
            <ul class="dropdown-menu" role="menu">
            {% for key, label in bmfmodule.create_views %}
                <li><a href="{% get_bmf_url object "report" key %}">{{ label }}</a></li>
            {% endfor %}
            </ul>
        </div>
        {% else %}
        <div class="btn-group">
            <a class="btn btn-bmfreport" href="{% get_bmf_url object "report" bmfmodule.report_views.0.0 %}">
                <span class="glyphicon glyphicon-print"></span> {% trans "Report" %}
            </a>
        </div>
        {% endif %}
    {% endif %}


    <div class="btn-group">
        {% if bmfactivity.notification %}
            {% if bmfactivity.watch %}
                <a href="{% url "djangobmf:notification-update" pk=bmfactivity.notification.pk %}" class="btn {% if bmfactivity.notification.unread %}btn-info{% else %}btn-default{% endif %} bmf-edit">
                    <span class="glyphicon glyphicon-star"></span>
                </a>
            {% else %}
                <a href="{% url "djangobmf:notification-update" pk=bmfactivity.notification.pk %}" class="btn btn-default bmf-edit">
                    <span class="glyphicon glyphicon-star-empty"></span>
                </a>
            {% endif %}
        {% else %}
            <a href="{% url 'djangobmf:notification-create' ct=bmfactivity.ct pk=object.pk %}" class="btn btn-default bmf-edit">
                <span class="glyphicon glyphicon-star-empty"></span>
            </a>
        {% endif %}

        {% if files %}
            <a class="btn btn-default btn-info" href="#">
                <span class="glyphicon glyphicon-paperclip"></span>
            </a>
        {% else %}
            <a class="btn btn-default btn-default disabled" href="#">
                <span class="glyphicon glyphicon-paperclip"></span>
            </a>
        {% endif %}

    </div>
</div>
<div class="clearfix"></div>
{% endblock %}

{% block base_content %}{{ block.super }}{% if related_views %}<ul class="nav nav-pills">
    {% for data in related_views.values|dictsort:"name" %}
    <li{% if data.active %} class="active"{% endif %}><a href="{% get_bmf_url object "detail" %}{% if not data.active %}?open={{ data.key }}{% endif %}">{{ data.name }}</a></li>
    {% endfor %}
</ul>{% endif %}{% endblock %}
